package com.zgm.ch05.aop.pointcutAdvisor.nameMatch._4_1_5;

import org.springframework.aop.Advisor;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.NameMatchMethodPointcut;

import com.zgm.ch05.aop.pointcutAdvisor._4_1_3.SimpleAdvice;

public class NamePointcutExample {

	public static void main(String[] args) {
		NameBean target = new NameBean();
		
		NameMatchMethodPointcut pc = new NameMatchMethodPointcut();
		pc.addMethodName("foo");
		pc.addMethodName("bar");
		Advisor advisor = new DefaultPointcutAdvisor(pc, new SimpleAdvice());
		ProxyFactory pf = new ProxyFactory();
		pf.setTarget(target);
		pf.addAdvisor(advisor);
		
		NameBean proxy = (NameBean) pf.getProxy();
		
		proxy.foo();
		proxy.foo(999);
		proxy.bar();
		proxy.zgm();
		
		
	}
}
